# -*- coding: utf-8 -*-
import os
import  requests
from lxml import etree
def cmd_download(url,filename):   #下载文件
	info = os.system(r'you-get --debug -o f:\1 -O {filename}  {url}'.format(filename=filename,url=url))
	return info
headers ={
	'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'
}
html = requests.get('http://v.youku.com/v_show/id_XMzI4Njk1NzMxMg==.html',headers=headers)
selector =etree.HTML(html.text)
titles = selector.xpath('//div[@class="item item-txt"]/@title')
filenames = map(lambda x:x.replace(' ',''),titles)
urls =selector.xpath('//div[@class="item item-txt"]/a/@href')
for url,filename in zip(urls, filenames):  #利用爬取的标题和URL进行下载
	url_link ="http:"+url
	print(url_link, filename)
	status_code = cmd_download(url_link,filename)
	if status_code:
		pass